from fastapi import APIRouter, Depends

from app.api.admin.schema.coupon.coupon import CouponDeleteInSchema, CouponDetailInSchema, CouponEditInSchema, CouponInSchema, CouponListInSchema, CouponOutSchema, CouponStatusInSchema
from app.api.admin.service.coupon.copon import CouponService
from app.common.schema import PageInationResult
from app.utils.res import unified_resp


coupon = APIRouter(
    prefix="/coupon",
    tags=["优惠券"],
)


@coupon.post("/list",response_model=PageInationResult[CouponOutSchema])
@unified_resp
async def list(coupon_list_in:CouponListInSchema,coupon_service: CouponService = Depends(CouponService.instance)):
    return await coupon_service.list(coupon_list_in)


@coupon.post("/detail")
@unified_resp
async def detail(detail_in: CouponDetailInSchema, coupon_service: CouponService = Depends(CouponService.instance)):
    return await coupon_service.detail(detail_in.coupon_id)


@coupon.post("/add")
@unified_resp
async def add(coupon_in: CouponInSchema, coupon_service: CouponService = Depends(CouponService.instance)):
    return await coupon_service.add(coupon_in)


@coupon.post("/edit")
@unified_resp
async def edit(coupon_in: CouponEditInSchema, coupon_service: CouponService = Depends(CouponService.instance)):
    return await coupon_service.edit(coupon_in)


@coupon.post("/delete")
@unified_resp
async def delete(del_in: CouponDeleteInSchema, coupon_service: CouponService = Depends(CouponService.instance)):
    return await coupon_service.delete(del_in)


@coupon.post("/change_status")
@unified_resp
async def change_status(status_in: CouponStatusInSchema, coupon_service: CouponService = Depends(CouponService.instance)):
    return await coupon_service.change_status(status_in)
